FROM php:7.3-fpm-alpine

# 国内的镜像下载速度喜人 需要更换
RUN echo http://mirrors.aliyun.com/alpine/v3.11/main/ > /etc/apk/repositories && \
    echo http://mirrors.aliyun.com/alpine/v3.11/community/ >> /etc/apk/repositories
RUN apk update && apk upgrade

# 安装依赖
RUN apk add --no-cache --virtual .build-deps \
    $PHPIZE_DEPS \
    curl-dev \
    imagemagick-dev \
    libtool \
    libxml2-dev \
    postgresql-dev \
    sqlite-dev

# 安装依赖
RUN apk add --no-cache \
    bash \
    curl \
    freetype-dev \
    g++ \
    gcc \
    git \
    imagemagick \
    libc-dev \
    libjpeg-turbo-dev \
    libpng-dev \
    libzip-dev \
    make \
    mysql-client \
    nodejs \
    nodejs-npm \
    oniguruma-dev \
    yarn \
    openssh-client \
    postgresql-libs \
    rsync \
    zlib-dev

# Install PECL and PEAR extensions
RUN pecl install \
    imagick

# Enable PECL and PEAR extensions
RUN docker-php-ext-enable \
    imagick

# gd的选项有变动 7.3 和 7.4不一样
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/freetype2 -with-png-dir=/usr/include --with-jpeg-dir=/usr/include

# Install php extensions
RUN docker-php-ext-install \
    bcmath \
    calendar \
    curl \
    exif \
    gd \
    iconv \
    mbstring \
    pdo \
    pdo_mysql \
    pdo_pgsql \
    pdo_sqlite \
    pcntl \
    tokenizer \
    xml \
    zip

# 安装redis
RUN pecl install redis-4.0.1 \
    && docker-php-ext-enable redis


RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

COPY ./swoole_loader73.so /usr/local/lib/php/extensions/no-debug-non-zts-20180731/swoole_loader73.so
COPY ./docker-php-ext-swoole.ini /usr/local/etc/php/conf.d/docker-php-ext-swoole.ini


# 安装 composer
ENV COMPOSER_HOME /composer
ENV PATH ./vendor/bin:/composer/vendor/bin:$PATH
ENV COMPOSER_ALLOW_SUPERUSER 1
RUN curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer

# 清理
RUN apk del -f .build-deps

# 设置进入目录
WORKDIR /var/www
